package cn.stylefeng.guns.modular.business.frequency.branchtenement.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import cn.stylefeng.guns.modular.business.frequency.branchtenement.model.param.BranchTenementParam;
import cn.stylefeng.guns.modular.business.frequency.branchtenement.service.BranchTenementService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 租户网点表 控制器
 *
 * @author: yujie
 * @date: 2023/05/10 16:17
 */
@RestController
public class BranchTenementController {

    @Resource
    private BranchTenementService branchTenementService;

    /**
     * 分页查询租户网点表
     *
     * @author yujie
     * @date 2023/05/10 16:17
     */
    @PostMapping("/branchTenement/page")
    @BusinessLog(title = "租户网点表_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(@RequestBody BranchTenementParam branchTenementParam) {
        return branchTenementService.page(branchTenementParam);
    }

    /**
     * 获取全部租户网点表
     *
     * @author yujie
     * @date 2023/05/10 16:17
     */
    @PostMapping("/branchTenement/list")
    @BusinessLog(title = "租户网点表_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(@RequestBody BranchTenementParam branchTenementParam) {
        return ResponseData.andaSuccess(branchTenementService.list(branchTenementParam));
    }

    /**
     * 查看详情租户网点表
     *
     * @author yujie
     * @date 2023/05/10 16:17
     */
    @GetMapping("/branchTenement/detail")
    @BusinessLog(title = "租户网点表_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(BranchTenementParam.detail.class) BranchTenementParam branchTenementParam) {
        return ResponseData.andaSuccess(branchTenementService.detail(branchTenementParam));
    }

    /**
     * 添加租户网点表
     *
     * @author yujie
     * @date 2023/05/10 16:17
     */
    @PostMapping("/branchTenement/add")
    @BusinessLog(title = "租户网点表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(BranchTenementParam.add.class) BranchTenementParam branchTenementParam) {
        branchTenementService.add(branchTenementParam);
        return ResponseData.andaSuccess();
    }

    /**
     * 删除租户网点表
     *
     * @author yujie
     * @date 2023/05/10 16:17
     */
    @PostMapping("/branchTenement/delete")
    @BusinessLog(title = "租户网点表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(BranchTenementParam.delete.class) BranchTenementParam branchTenementParam) {
        branchTenementService.delete(branchTenementParam);
        return ResponseData.andaSuccess();
    }

    /**
     * 编辑租户网点表
     *
     * @author yujie
     * @date 2023/05/10 16:17
     */
    @PostMapping("/branchTenement/edit")
    @BusinessLog(title = "租户网点表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(BranchTenementParam.edit.class) BranchTenementParam branchTenementParam) {
        branchTenementService.edit(branchTenementParam);
        return ResponseData.andaSuccess();
    }


}
